import Vue from 'vue'
import App from './app.vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import router from './router'
import axios from 'axios'
// 新增图标相关样式
import 'element-ui/lib/theme-chalk/icon.css'
// 添加在ElementUI引入之后
import '@/assets/css/dark-mode.css'
import '@/assets/css/variables.css';
axios.defaults.baseURL = 'http://localhost:8080'
axios.defaults.headers.post['Content-Type'] = 'application/json'

// 添加请求拦截器
axios.interceptors.request.use(config => {
  // 排除登录请求
  if (!config.url.includes('/user/login')) {
    const token = JSON.parse(localStorage.getItem('user') || '{}').token
    if (token) {
      config.headers.Authorization = `Bearer ${token}`
    }
  }
  return config
}, error => {
  return Promise.reject(error)
})

Vue.prototype.$axios = axios
Vue.prototype.$bus = new Vue()
Vue.use(ElementUI)


new Vue({
  router,
  render: (h) => h(App)
}).$mount('#app')
